<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ page import="com.liuya.db.sql.xml.DefineVariable" %>
<%@ page import="com.liuya.safe.policy.handler.AbstractPolicyDesignHandler" %>
<%@ page import="com.liuya.db.sql.xml.ContextValue" %>
<%@ page import="com.liuya.common.I18N" %>

<%
    I18N i18n = I18N.getInstance();

    DefineVariable[] variables = (DefineVariable[]) request.getAttribute("variables");
    AbstractPolicyDesignHandler handler = (AbstractPolicyDesignHandler) request.getAttribute("handler");
    String id = request.getParameter("id");
%>

<table class="ralaTable">
    <tr>
        <th><%=i18n.say("Name")%>
        </th>
        <th><%=i18n.say("Type")%>
        </th>
        <th><%=i18n.say("Value")%>
        </th>
        <th><%=i18n.say("Action")%>
            <a href="javascript:selectAddVariableType()" title="Add"><img src="/style/images/add.gif"/></a>
        </th>
    </tr>

    <% for (int i = 0; i < variables.length; i++) {
        DefineVariable var = variables[i];
        String[] format = handler.format(var);
    %>
    <tr>
        <td><%=format[1]%>
        </td>
        <td><%=i18n.say(format[0])%>
        </td>
        <td><%=format[2]%>
        </td>
        <td>
            <a href="javascript:editVariable(<%=i %>);" title="<%=i18n.say( "Edit" )%>"><img src="/style/images/edit.gif"/></a>
            <a href="javascript:deleteVariable(<%=i %>);" title="<%=i18n.say( "Delete" )%>"><img
                    src="/style/images/delete.gif"/></a>
        </td>
    </tr>
    <% } %>
</table>